import { contextBridge, ipcRenderer } from "electron";

//通过contextBridge 向渲染进程暴露一个全局的window.electronAPI
contextBridge.exposeInMainWorld('electronAPI', {

  close: (newTitle: string) => { ipcRenderer.send('close', newTitle) },

  ping: async (data: string) => {
    const result = await ipcRenderer.invoke('ping', data);
    return result;
  },

  minimize: (newTitle: string) => { ipcRenderer.send('minimize', newTitle) },

  maximize: (newTitle: string) => { ipcRenderer.send('maximize', newTitle) },
  
  onWindowStateChange: (callback: (event: Electron.IpcRendererEvent, ...args: unknown[]) => void) => ipcRenderer.on('window-state', callback),
});

